home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / libcruft / ranlib / gengam.f < prev    next >
Text File  |  1996-07-19  |  2KB  |  61 lines

  1.       REAL FUNCTION gengam(a,r)
  2. C**********************************************************************
  3. C
  4. C     REAL FUNCTION GENGAM( A, R )
  5. C           GENerates random deviates from GAMma distribution
  6. C
  7. C
  8. C                              Function
  9. C
  10. C
  11. C     Generates random deviates from the gamma distribution whose
  12. C     density is
  13. C          (A**R)/Gamma(R) * X**(R-1) * Exp(-A*X)
  14. C
  15. C
  16. C                              Arguments
  17. C
  18. C
  19. C     A --> Location parameter of Gamma distribution
  20. C                              REAL A
  21. C
  22. C     R --> Shape parameter of Gamma distribution
  23. C                              REAL R
  24. C
  25. C
  26. C                              Method
  27. C
  28. C
  29. C     Renames SGAMMA from TOMS as slightly modified by BWB to use RANF
  30. C     instead of SUNIF.
  31. C
  32. C     For details see:
  33. C               (Case R >= 1.0)
  34. C               Ahrens, J.H. and Dieter, U.
  35. C               Generating Gamma Variates by a
  36. C               Modified Rejection Technique.
  37. C               Comm. ACM, 25,1 (Jan. 1982), 47 - 54.
  38. C     Algorithm GD
  39. C
  40. C               (Case 0.0 <= R <= 1.0)
  41. C               Ahrens, J.H. and Dieter, U.
  42. C               Computer Methods for Sampling from Gamma,
  43. C               Beta, Poisson and Binomial Distributions.
  44. C               Computing, 12 (1974), 223-246/
  45. C     Adapted algorithm GS.
  46. C
  47. C**********************************************************************
  48. C     .. Scalar Arguments ..
  49.       REAL a,r
  50. C     ..
  51. C     .. External Functions ..
  52.       REAL sgamma
  53.       EXTERNAL sgamma
  54. C     ..
  55. C     .. Executable Statements ..
  56.       gengam = sgamma(r)
  57.       gengam = gengam/a
  58.       RETURN
  59.  
  60.       END
  61.